/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.djdb.shop;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;

/**
* @author Lieven Roegiers
* @copyright 2013
* @from MY_SHOP
*/
@Entity
@NamedQueries({
    @NamedQuery(name="Client.findAll",query="SELECT c FROM Client c"),
    @NamedQuery(name="Client.findByClientId",query="SELECT c FROM Client c WHERE c.id = :clientid"),
    @NamedQuery(name="Client.findByOrderId",query="SELECT o FROM Order o WHERE o.id = :orderid"),
})
public class Client  implements Serializable{
    @Id @GeneratedValue(generator = "CLIENT_ID")
    private int id;
    @Transient
    List <Person> persons ;
    @Transient
    List <Order> orders ;
    public List<Order> getOrders() {
        return Collections.unmodifiableList(orders);//orders;
    }
    public boolean addOrders(Order ... a){
        return orders.addAll(Arrays.asList(a));
    }
    //remove
    //clear
    public void clearOrders() {
        orders.clear();
    }
    public int getId(){
        return id;
    }
}
